package com.example.wananrdroid;

import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;

import com.example.wananrdroid.adapter.Vpadapter;
import com.example.wananrdroid.fragment.GuangFragment;
import com.example.wananrdroid.fragment.ZhuFragment;

import java.util.ArrayList;

public class MainActivity extends AppCompatActivity {

    private ViewPager mMainVp;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initViews();
    }

    private void initViews() {
        mMainVp = findViewById(R.id.main_vp);
        ArrayList<Fragment> fragments = new ArrayList<>();
        fragments.add(new GuangFragment());
        fragments.add(new ZhuFragment());
        Vpadapter vpadapter = new Vpadapter(getSupportFragmentManager(), fragments);
        mMainVp.setAdapter(vpadapter);
        mMainVp.setCurrentItem(1);
    }
}
